using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "MovementDetails_", menuName = "游戏SO文件/移动/移动细节数据")]
public class MovementDetailsSO : ScriptableObject
{
    #region Header MOVEMENT DETAILS

    [Space(10)]
    [Header("移动细节")]

    #endregion Header

    #region Tooltip

    [Tooltip("最小移动速度。GetMoveSpeed 方法计算最小值和最大值之间的随机值")]

    #endregion Tooltip

    public float minMoveSpeed = 8f;

    #region Tooltip

    [Tooltip("最大移动速度。GetMoveSpeed 方法计算最小值和最大值之间的随机值")]

    #endregion Tooltip

    public float maxMoveSpeed = 8f;

    #region Tooltip

    [Tooltip("如果有滚动运动 - 这是滚动速度")]

    #endregion

    public float rollSpeed; // for player

    #region Tooltip

    [Tooltip("如果有滚动运动 - 这是滚动距离")]

    #endregion

    public float rollDistance; // for player

    #region Tooltip

    [Tooltip("如果有滚动运动 - 这是滚动动作之间的冷却时间（以秒为单位）")]

    #endregion

    public float rollCooldownTime; // for player

    /// <summary>
    /// 获取最小值和最大值之间的随机移动速度
    /// </summary>
    public float GetMoveSpeed()
    {
        if (minMoveSpeed == maxMoveSpeed)
        {
            return minMoveSpeed;
        }
        else
        {
            return Random.Range(minMoveSpeed, maxMoveSpeed);
        }
    }

    #region Validation

#if UNITY_EDITOR

    private void OnValidate()
    {
        HelperUtilities.ValidateCheckPositiveRange(this, nameof(minMoveSpeed), minMoveSpeed, nameof(maxMoveSpeed),
            maxMoveSpeed, false);
        if (rollDistance != 0f || rollSpeed != 0 || rollCooldownTime != 0)
        {
            HelperUtilities.ValidateCheckPositiveValue(this, nameof(rollDistance), rollDistance, false);
            HelperUtilities.ValidateCheckPositiveValue(this, nameof(rollSpeed), rollSpeed, false);
            HelperUtilities.ValidateCheckPositiveValue(this, nameof(rollCooldownTime), rollCooldownTime, false);
        }
    }

#endif

    #endregion Validation
}